]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ibusManager: Avoid changes to ibus-typing-booster configuration
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 30 Jan 2024 10:24:56 +0000 (11:24 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 29 Feb 2024 15:42:22 +0000 (16:42 +0100)
The ibus-typing-booster IM module is already meant to do the "right"
thing when the IBus.Capabilite.OSK hint is passed to the IM. We do
already honor that hint (commit 23bfd08b3c9), and ibus-typing-booster
has been doing this for a reasonably long time (first release seems
to be 2.19.9 dated 2 years ago, current is 2.24.12).

Drop this mangling of foreign settings, and let ibus-typing-booster
figure out the optimal configuration given the presence of an OSK.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3162>

js/misc/ibusManager.js

index 510561b4d0defe552ae4dda6818d52f5f9ff2ecd..c3022aaa6d13b3ecf87b97b5230d916aa382247a 100644 (file)
@@ -28,11 +28,6 @@ let _ibusManager = null;
 const IBUS_SYSTEMD_SERVICE = 'org.freedesktop.IBus.session.GNOME.service';
 
 const TYPING_BOOSTER_ENGINE = 'typing-booster';
-const IBUS_TYPING_BOOSTER_SCHEMA = 'org.freedesktop.ibus.engine.typing-booster';
-const KEY_EMOJIPREDICTIONS = 'emojipredictions';
-const KEY_DICTIONARY = 'dictionary';
-const KEY_INLINECOMPLETION = 'inlinecompletion';
-const KEY_INPUTMETHOD = 'inputmethod';
 
 function _checkIBusVersion(requiredMajor, requiredMinor, requiredMicro) {
     if ((IBus.MAJOR_VERSION > requiredMajor) ||
@@ -313,8 +308,8 @@ class IBusManager extends Signals.EventEmitter {
     }
 
     async setEngine(id, callback) {
-        if (this._preOskState)
-            this._preOskState.engine = id;
+        if (this._oskCompletion)
+            this._preOskEngine = id;
 
         const isXkb = id.startsWith('xkb:');
         if (this._oskCompletion && isXkb)
@@ -365,40 +360,13 @@ class IBusManager extends Signals.EventEmitter {
             return true;
 
         this._oskCompletion = enabled;
-        let settings =
-            new Gio.Settings({schema_id: IBUS_TYPING_BOOSTER_SCHEMA});
 
         if (enabled) {
-            this._preOskState = {
-                'engine': this._currentEngineName,
-                'emoji': settings.get_value(KEY_EMOJIPREDICTIONS),
-                'langs': settings.get_value(KEY_DICTIONARY),
-                'completion': settings.get_value(KEY_INLINECOMPLETION),
-                'inputMethod': settings.get_value(KEY_INPUTMETHOD),
-            };
-            settings.reset(KEY_EMOJIPREDICTIONS);
-
-            const removeEncoding = l => l.replace(/\..*/, '');
-            const removeDups = (l, pos, arr) => {
-                return !pos || arr[pos - 1] !== l;
-            };
-            settings.set_string(
-                KEY_DICTIONARY,
-                GLib.get_language_names().map(removeEncoding)
-                    .sort().filter(removeDups).join(','));
-
-            settings.reset(KEY_INLINECOMPLETION);
-            settings.set_string(KEY_INPUTMETHOD, 'NoIME');
+            this._preOskEngine = this._currentEngineName;
             this._setEngine(TYPING_BOOSTER_ENGINE, callback);
-        } else if (this._preOskState) {
-            const {engine, emoji, langs, completion, inputMethod} =
-                  this._preOskState;
-            this._preOskState = null;
-            this._setEngine(engine, callback);
-            settings.set_value(KEY_EMOJIPREDICTIONS, emoji);
-            settings.set_value(KEY_DICTIONARY, langs);
-            settings.set_value(KEY_INLINECOMPLETION, completion);
-            settings.set_value(KEY_INPUTMETHOD, inputMethod);
+        } else if (this._preOskEngine) {
+            this._setEngine(this._preOskEngine, callback);
+            delete this._preOskEngine;
         }
         return true;
     }